<%@ page import="cn.itlaobing.service.VegetableService" %>
<%@ page import="cn.itlaobing.entity.VegetablesDTO" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.itlaobing.util.PageUtil" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>蔬菜进口管理系统</title>
    <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css">


<body>
<script>

</script>
    <%!
        public String getColor(int i){
            return i%2==0?"#00AAFF":"#CCDF14";
        }
    %>
    <div class="container">
        <div class="row">
            <table align="text-center"  style="border: 1px black solid;width: 500px;height: 400px">
                <caption align="left"><h2>蔬菜进口管理系统</h2></caption>
                <thead>
                    <tr>
                        <th>蔬菜进口单编号</th>
                        <th>蔬菜种类</th>
                        <th>数量</th>
                        <th>编辑</th>
                        <th>删除</th>
                    </tr>
                </thead>
                <tbody>
                   <%-- <%
                        VegetableService vegetableService=new VegetableService();
                        List<VegetablesDTO> list=vegetableService.queryAll();
                        for(int i=0;i<list.size();i++){
                            VegetablesDTO vd=list.get(i);

                    %>
                    <tr bgcolor="<%=getColor(i)%>" align="center">
                        <td><%=vd.getId()%></td>
                        <td><%=vd.getName()%></td>
                        <td>
                            <fmt:formatNumber  pattern="0.00">
                                <%=vd.getQuantity()%>
                            </fmt:formatNumber>

                        </td>
                        <td><a href="update.jsp?id1=${vd.getId()}">编辑</a></td>
                        <td>
                            <a href="${pageContext.request.contextPath}/vegetableservlet/delete?id2=${vd.getId()}">删除</a>
                        </td>
                    </tr>

                    <%
                        }
                    %>--%>
                    <c:if test=" ${ empty DATAS}">
                        <td>你妹的</td>
                    </c:if>
                    <c:forEach var="m" items="${DATAS}">
                        <tr>
                            <td>${m.id}</td>
                            <td>${m.name}</td>
                            <td>
                                <fmt:formatNumber pattern="0.00" value="${m.quantity}"/>
                            </td>
                        </tr>
                    </c:forEach>
                    <tr>
                        <td colspan="9" align="center">
                            <%
                                PageUtil pageUtil=(PageUtil)request.getAttribute("pageUtil");
                                if(pageUtil!=null){
                                    if(pageUtil.getPageIndex()!=1){

                            %>
                                <a href="${pageContext.request.contextPath}/vegetableservlet/query
                                ?pageIndex=1">首页</a>&nbsp;
                                <a href="${pageContext.request.contextPath}/vegetableservlet/query
                                ?pageIndex=${pageUtil.pageIndex-1}">上一页</a>&nbsp;
                            <%
                                }else{

                            %>
                                第一页&nbsp;
                                上一页&nbsp;
                            <%
                                }
                                if(pageUtil.getPageIndex()!=pageUtil.getPageCount()){
                            %>
                                <a href="${pageContext.request.contextPath}/vegetableservlet/query
                                ?pageIndex=${pageUtil.pageIndex+1}">下一页</a>&nbsp;
                                 <a href="${pageContext.request.contextPath}/vegetableservlet/query
                                 ?pageIndex=${pageUtil.pageCount}">末页</a>&nbsp;

                            <%
                                }else {
                            %>
                                下一页&nbsp;
                                末页&nbsp;
                            <%
                                }
                                }
                            %>

                        </td>
                    </tr>

                </tbody>

            </table>


        </div>
    </div>
</body>
</html>
